This invention relates to a two-dimensional code reader for reading two-dimensional code.
Conventional two-dimensional code read means uses a CCD area sensor as a sensor and performs processing in the order of (1) binarizing analog image information output from the CCD area sensor, (2) detecting two-dimensional code from binarized image data, and (3) extracting cell data of the detected two-dimensional code, as shown in Japanese Patent Laid-Open No. Hei 7-234915.
The following three methods are executed as the step in (1):
The first binarization method is to compare an image signal sent from the CCD area sensor with a given threshold value for binarization. FIG. 26(b) shows an example of a binarization circuit with a fixed threshold value. Analog signal voltage output from the CCD area sensor enters input Vin and is compared with voltage Eo. If the analog signal voltage is higher than the voltage Eo, a signal of 1 is output; if the analog signal voltage is lower than the voltage Eo, a signal of 0 is output. In FIG. 26(a), the portion of waveform Vin higher than the value of the voltage Eo becomes 0 (white) and the portion of waveform Vin lower than the value of the voltage Eo becomes 1 (black).
The second binarization method is to compare an image signal with a floating threshold value found from a slightly preceding image signal for binarization. FIG. 26(c) shows an example of a binarization-circuit with a floating threshold value. The binarization circuit uses Ev provided by low-frequency filtering (integrating) input signal Vin as a threshold value. The threshold value Ev becomes Ev in FIG. 26(a). If Vin is higher than Ev, 0 (white) is output; if Vin is lower than Ev, 1 (black) is output.
The third binarization method is a method of converting an analog image signal output from the CCD area sensor into digital form, storing a 1-screen image signal in an image memory, and using information of a gray level distribution of the image for binarization. FIG. 23 is an example of the binarization method. First, a shading (luminance unevenness) correction for removing the effect of luminance unevenness, etc., is made on the whole screen for the image stored in the image memory at step 51. For the shading correction, a method of removing a low-frequency component from the image through a homomorphic filter is available, for example. Next, a gray level distribution histogram of the image is prepared and a threshold value is found by a 2-mode method at step 52.
As the step in (2) after the binarization is executed, two-dimensional code is detected. To detect two-dimensional code is to detect the position of the two-dimensional code. A method using chain coding, for example, as disclosed in Japanese Patent Publication No. Hei 1-35385 is often used for detecting the two-dimensional code position.
The chain coding, which is a method of finding the outline of a figure, traces the boundary between black pixels 241 and white pixels 242 (243), finds the outline of the figure, and detects the two-dimensional code.
Particularly, a method using Hough transformation is proposed as in Japanese Patent Laid-Open No. Hei 7-234915 as a detection method of two-dimensional code having at least two outer sides as straight lines like two-dimensional code 20.
The Hough transformation is a method of globally extracting points arranged on a line in an image and is known as effective line detection means. In Japanese Patent Laid-Open No. Hei 7-234915, the Hough transformation is used to detect two sets of lines and two-dimensional code is detected.
Line detection using the Hough transformation will be discussed with reference to FIGS. 25(a) and (b). The image memory is scanned with a given spacing in a longitudinal direction to find an edge point. A sine curve corresponding to the coordinates of the found edge point is drawn on .theta. (angle)-.rho. (distance) plane. For example, edge points 251, 252, 253, and 254 are converted into curves 256, 257, 258, and 259 on the .theta.-.rho. plane. If the edge points are arranged in a line like the edge points 251, 252, and 253, three sine curves cross as at point 260 in FIG. 25(b). In fact, quantization is executed on the .theta.-.rho. plane and votes are given to the point (.theta.,.rho.) one by one correspondingly to the sine curves passing through that point. Thus, three votes are given to the point 260. Points to which a large number of votes are given like the point 260 are found, whereby line 255 can be detected.
After the two-dimensional code is detected, in the step in (3), the position of the center point of each cell of the two-dimensional code is found and binary data of the center point of the each cell is extracted. At this time, since binarization is already executed in the step in (1), the gray level of the pixel at the center point of each cell is simply read, whereby binary data of the cell can be extracted.
The binarization methods in the conventional examples involve the following problems:
In the first binarization method using a fixed threshold value, precise binarization can be executed if image contrast is good and luminance unevenness, etc., does not exist; if contrast is poor or if luminance unevenness is caused by affection of applied illumination light, correct binarization cannot be executed. If fine lines or small points extend across the light receiving elements of the sensor, they are often ignored because no sufficient output may be provided like 221 in FIG. 26(a).
The second binarization method, which binarizes using a floating threshold value, solves the problems of the first binarization method, such as luminance unevenness and loss of fine lines, etc. However, even in the second binarization method, normal binarization cannot be executed for a waveform in which black signal less than Eo continuously elongates due to luminance unevenness. This means that an area where black continues in the direction along the image signal and luminance unevenness exists cannot correctly be binarized.
The third binarization method solves the problems of the first and second binarization methods. However, all image information is once stored in the image memory and shading correction and binarization processing are executed for all image information, thus it takes very long processing time.
The conventional two-dimensional code detection involves the following problems:
In the detection processing using the chain coding described above, if a figure with a flaw 244 as in FIG. 24(b) is read, the flaw part is recognized as a contour as indicated by an arrow 245 in FIG. 24, namely, a contour different from the original contour is recognized and two-dimensional code cannot correctly be detected.
In the detection using the Hough transformation as described above, unlike the detection processing using the chain coding, global line detection is executed as described above, so that line detection can be executed without receiving the effect of a flaw, etc. However, since a large number of edge points are converted into sine curves to execute line detection using the Hough transformation, the computation amount increases and it takes processing time.